package com.kaibes.module.login;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import com.kaibes.web.response.ResponseConfig;
import com.kaibes.web.response.StatusBody;
import com.kaibes.web.status.StatusConfig;

@Configuration
public class LoginConfig implements InitializingBean {

    @Autowired
    private StatusConfig statusConfig;
    @Autowired
    private ResponseConfig responseConfig;

	@Override
	public void afterPropertiesSet() throws Exception {
		statusConfig.putStatusView(HttpServletResponse.SC_UNAUTHORIZED, "/admin/login");
        StatusBody body = new StatusBody();
        body.setMessage("您没有登录，或者登录已过期，请重新登录。");
        body.setRedirect("/admin/login");
        responseConfig.putStatusBody(HttpServletResponse.SC_UNAUTHORIZED, body);
	}

}
